from django.contrib import admin
from polls.models import Poll,Choice,Author,Author_Polls

class ChoiceInline(admin.TabularInline):
    model = Choice
    extra = 3

class PollAdmin(admin.ModelAdmin):
    #Creer un champ pour le tri
    list_filter = ['pub_date']
    """fieldsets = [
        (None,               {'fields': ['question']}),
        ('Date information', {'fields': ['pub_date'], 'classes': ['collapse']}),
    ]"""
    list_display = ('question','authors','pub_date', 'was_published_recently')
    
    #Inclure un ChoiceInline a la creation d'un poll 
    inlines = [ChoiceInline]

admin.site.register(Poll, PollAdmin)

admin.site.register(Author)
admin.site.register(Author_Polls)